package Test2;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.junit.Test;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Properties;

public class DuridTest {

    public static void main(String[] args) throws Exception {

    }


    @Test
    public void TestDEL() throws Exception {
        int id =10;

        Properties prop = new Properties();
        prop.load(new FileInputStream("src/druid.properties"));
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
        Connection conn = dataSource.getConnection();

        String sql = "DELETE from tb_brand where id =?";
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1,id);
        int i = pstmt.executeUpdate();
        System.out.println(i>0);
        pstmt.close();
        conn.close();
    }


}
